<template>
  <div class="add">
    <el-dialog title="收货地址" :visible.sync="dialogFormVisible">
      <el-form :model="form">
        <el-form-item label="小区名称" :label-width="formLabelWidth">
          <el-input v-model="form.Villagename" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="标题" :label-width="formLabelWidth">
          <el-input v-model="form.title" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="面积" :label-width="formLabelWidth">
          <el-input v-model="form.Size" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="总价" :label-width="formLabelWidth">
          <el-input v-model="form.price" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="排序" :label-width="formLabelWidth">
          <el-input v-model="form.sort" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="状态" :label-width="formLabelWidth">
          <el-input v-model="form.state" autocomplete="off"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="btnopen">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  data() {
    return {
      form: {
        Villagename: "",
        title: "",
        Size: "",
        price: "",
        sort: "",
        state: "",
      },
      formLabelWidth: "120px",
      dialogFormVisible: false,
    };
  },
  methods: {
    btnopen() {
      if (this.form.id) {
        this.$http
          .post("/api/findRental", {
            ...this.form,
          })
          .then((res) => {
            console.log(res);
            if (res.data.code === 1) {
              this.$message.success("编辑成功");
              this.$emit("update");
              this.dialogFormVisible = false;
            }
          });
      } else {
        this.$http
          .post("/api/addNewdreass", {
            ...this.form,
          })
          .then((res) => {
            console.log(res);
            if (res.data.code === 1) {
              this.$message.success("添加成功");
              this.$emit("update");
              this.dialogFormVisible = false;
            }
          });
      }
    },
  },
};
</script>

<style>
</style>